package cn.u313.listener;

import cn.u313.comm.utils.MsgUtil;
import cn.u313.comm.utils.Util;
import cn.u313.service.YanYuEntryService;
import love.forte.simbot.annotation.Filter;
import love.forte.simbot.annotation.OnGroup;
import love.forte.simbot.api.message.events.GroupMsg;
import love.forte.simbot.api.sender.MsgSender;
import love.forte.simbot.filter.MatchType;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class YanYuListen extends BaseListen{
    @Autowired
    YanYuEntryService yanYuEntryService;

    @OnGroup
    @Filter("嘤鱼系统")
    public  void mean(GroupMsg msg, MsgSender msgSender){
        sendMsg(msgSender,msg, Util.icon +
                "嘤鱼系统            \n"+Util.icon+
                "购买嘤鱼 (200悦币)  \n"+Util.icon+
                "嘤鱼等级            \n"+Util.icon+
                "投喂嘤料【数量】    \n"+Util.icon+
                "大鱼吃小鱼    \n"+ Util.icon+
                "更多功能开发中    ");
    }

    @OnGroup
    @Filter("获取嘤鱼")
    public  void gsetyu(GroupMsg groupMsg, MsgSender msgSender){
        getyu(groupMsg,msgSender);
    }
    @OnGroup
    @Filter(value = "购买嘤鱼")
    public  void getyu(GroupMsg groupMsg, MsgSender msgSender){

        String qq=getQQ(groupMsg);
        String group = getGroup(groupMsg);
        String sendMsg = yanYuEntryService.pay(qq,group);
        sendMsg(msgSender,groupMsg,sendMsg);
    }

    /**
     * 吃他
     * @param groupMsg
     * @param msgSender
     */
    @OnGroup
    @Filter(value = "吃他", matchType = MatchType.CONTAINS)
    @Filter(value = "大鱼吃小鱼", matchType = MatchType.CONTAINS)
    public  void eatFish(GroupMsg groupMsg, MsgSender msgSender){

        String qq=getQQ(groupMsg);
        String qq1=getQQ1(groupMsg);
        String group = getGroup(groupMsg);
        String sendMsg = yanYuEntryService.eat(qq,qq1,group);
        sendMsg(msgSender,groupMsg,sendMsg);
    }
//    /**
//     * 吃他
//     * @param groupMsg
//     * @param msgSender
//     */
//    @OnGroup
//    @Filter(value = "嘤鱼等级", matchType = MatchType.CONTAINS)
//    public  void selectYingYu(GroupMsg groupMsg, MsgSender msgSender){
//
//        String qq=getQQ1(groupMsg);
//        if(qq == null)
//            qq=getQQ(groupMsg);
//        String group = getGroup(groupMsg);
//        String sendMsg = yanYuEntryService.get(qq,group);
//        sendMsg(msgSender,groupMsg,sendMsg);
//    }
    @OnGroup
    @Filter(value = "投喂", matchType = MatchType.CONTAINS)
    @Filter(value = "喂鱼", matchType = MatchType.CONTAINS)
    public  void weiYu(GroupMsg groupMsg, MsgSender msgSender){
        int n=0;
        try {
            n=new Integer(Util.getSubUtil1(groupMsg.getMsg(),"【(.*?)】"));
        } catch (Exception e) {
            n=10;
        }

        n=n<0?-n:n;
        String qq=getQQ(groupMsg);
        String group = getGroup(groupMsg);
        String sendMsg = yanYuEntryService.touWei(qq,group,n);
        sendMsg(msgSender,groupMsg,sendMsg);

    }
    @OnGroup
    @Filter(value = "卖嘤鱼肉", matchType = MatchType.CONTAINS)
    @Filter(value = "卖鱼", matchType = MatchType.CONTAINS)
    @Filter(value = "卖肉", matchType = MatchType.CONTAINS)
    public  void maiYu(GroupMsg groupMsg, MsgSender msgSender){
        int n=0;
        try {
            n=new Integer(Util.getSubUtil1(groupMsg.getMsg(),"【(.*?)】"));

            n=n<0?-n:n;
        } catch (Exception e) {
            n=10;
        }

        n=n<0?-n:n;
        String qq=getQQ(groupMsg);
        String group = getGroup(groupMsg);
        String sendMsg = yanYuEntryService.maiYu(qq,group,n);
        sendMsg(msgSender,groupMsg,sendMsg);

    }
    @OnGroup
    @Filter(value = "嘤鱼等级")
    @Filter(value = "等级")
    @Filter(value = "小鱼儿",matchType = MatchType.CONTAINS)
    public  void yYu(GroupMsg groupMsg, MsgSender msgSender){

        String qq=getQQ1(groupMsg);
        if(qq==null)
            qq= getQQ(groupMsg);
        String group = getGroup(groupMsg);
        String sendMsg = yanYuEntryService.yYu(qq,group);
        sendMsg(msgSender,groupMsg,sendMsg);

    }
}
